package com.hy;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.context.annotation.Bean;
import org.springframework.web.client.RestTemplate;

/**
 * Created With IntelliJ IDEA.
 * Descriptions:
 * author: Mr.Du
 * Date: 2022/10/19
 * Time: 20:00
 */
@SpringBootApplication
//@EnableEurekaClient //将当前项目作为Eureka Client注册到Eureka Service中，只能在eureka中使用
@EnableDiscoveryClient //也是将当前项目作为Eureka Client注册到Eureka Service中   可以在所有注册服务中使用
@EnableCircuitBreaker    // 开启熔断
//@EnableFeignClients     // 开启Feign客户端   需要注销上面的@EnableCircuitBreaker，因为引用Feign会自动启动熔断
public class PageApplication {
    
    public static void main(String[] args) {
        SpringApplication.run(PageApplication.class,args);
    }
    
    @Bean
    @LoadBalanced   // 启用负载均衡
    public RestTemplate restTemplate(){
        return new RestTemplate();
    }
    
}
